package com.yixiu.study.juc.locksupport;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;

/**
 * @CalssName T01_LockSupport
 * @Description
 * @Author yixiu
 * @Date 2021/6/25 10:16
 * @Verison num1.0
 **/
public class T01_LockSupport {

    public static void main(String[] args) {
        Thread t = new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                System.out.println(i);
                if(i == 5){
                    LockSupport.park();
                }
                if(i == 8){
                    LockSupport.park();
                }
            }

            try {
                TimeUnit.SECONDS.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        });

        t.start();
        LockSupport.unpark(t);
//        LockSupport.unpark(t);

    }

}
